
<h1><?php echo $title; ?></h1>
<div class="noprint">
<?php if (isset($notice) || $notice = $this->session->flashdata('notification')):?>
<p class="notice"><?php echo $notice;?></p>
<?php endif;?>

<?php if (!$rows) : ?>
<p class="notice"><?php echo __("Nessuno risultato", $module);?></p>
<?php endif; ?>

<ul style='border-left: 3px dashed red;'><b>Aggiornamenti:</b><li>Clicca sul numero di ID per visualizzare l'adozione</li></ul>

<form method='post' action="<?php echo site_url('adozioni/anagrafica/adozioni/results') ?>"  name="searchform" style="display: inline">
<label for="filter[id]"><?php echo __("Id scheda", $module) ?></label>
<input type="text" name="filter[id]" id="filter[id]" size="10" value="<?php if(isset($filter['id'])) echo $filter['id'] ?>" />

<label for="filter[id_missione]"><?php echo __("Missione", $module) ?></label>
<select name="filter[id_missione]">
<option></option>
<?php foreach($missioni as $m): ?>
<option value="<?php echo $m['id'] ?>" <?php if(isset($filter['id_missione']) && $m['id'] == $filter['id_missione']) echo " selected "; ?>><?php echo $m['nome']; ?></option>
<?php endforeach; ?>
</select>


<label for="filter[sostenitore]"><?php echo __("Sostenitore", $module) ?></label>
<input type="text" name="filter[sostenitore]" id="filter[sostenitore]" value="<?php if(isset($filter['sostenitore'])) echo $filter['sostenitore'] ?>" />
<label for="filter[assistito]"><?php echo __("Assistito", $module) ?></label>
<input type="text" name="filter[assistito]" id="filter[assistito]" value="<?php if(isset($filter['assistito'])) echo $filter['assistito'] ?>" />

<?php /*

<select name="filter[id_tiposostegno]">
<option></option>
<?php foreach($tiposostegno as $m): ?>
<option value="<?php echo $m['id'] ?>" <?php if(isset($filter['id_tiposostegno']) && $m['id'] == $filter['id_tiposostegno']) echo " selected "; ?>><?php echo $m['nome']; ?></option>
<?php endforeach; ?>
</select>
*/ ?>
<?php /*
<?php var_dump($filter); ?>

<select name="filter[id_stato]">
<option></option>
<?php foreach($stati as $m): ?>
<option value="<?php echo $m['id'] ?>" <?php if(isset($filter['id_stato']) && $m['id'] == $filter['id_stato']) echo " selected "; ?>><?php echo $m['nome']; ?></option>
<?php endforeach; ?>
</select>
*/ ?>
<input type="submit" name="submit" value="   <?php echo __('Ok', $module) ?>   " />
<input type='hidden' name='filter[trashed]' value="<?php echo $filter['trashed'] ; ?>" />
<?php foreach($filter['id_stato'] as $t): ?>
<input type='hidden' name='filter[id_stato][]' value="<?php echo $t ; ?>" />
<?php endforeach; ?>

</form>
<?php if(count($filter) > 1): ?>
<br />
<form method='post' name='frmstampalettera' action="<?php echo site_url('adozioni/anagrafica/adozioni/stampalettere') ?>" style="display: inline; ">
<input type="submit" name="stampalettere" value="<?php echo __("Stampa lettere / Buste / CCP", $module) ?>" />
</form>


<form method='post' name='frmstampalettera' action="<?php echo site_url('adozioni/anagrafica/adozioni/stampa') ?>" style="display: inline; " target="_blank">
<input type="submit" name="stampalettera" value="<?php echo __("Stampa scheda", $module) ?>" />
</form>

<form method='post' name='salva_filtro' action="<?php echo site_url('adozioni/ricerca/ricerche/save') ?>" style="display: inline; ">
<label for="nome_ricerca"><?php echo __("Salva risultato", $module) ?></label>
<input type="hidden" name="controller" value="adozioni" />
<input type="text" name="nome_ricerca" id="nome_ricerca" />
<input type="submit" name="salva_ricerca" value="<?php echo __("Ok", $module) ?>" />
</form>
<?php endif; ?>

<form method='post' name='frmexcel' action="<?php echo site_url('adozioni/anagrafica/adozioni/results') ?>" style="display: inline; ">
<input type="submit" name="excel" value="<?php echo __("Esporta in Excel", $module) ?>" />
</form>



</div>
<table class="list" cellpadding=3 >
	<thead>
		<tr>
				<th width="3%" class="center">#</th>
				<th width="5%" class="center"><?php echo anchor('adozioni/anagrafica/adozioni/order_by/ad.id', "ID") ?></th>
				<th><?php echo anchor('adozioni/anagrafica/adozioni/order_by/s.nomecognome',__("Sostenitore", $module), array('id' => 's.nomecognome'))?></th>
				<th><?php echo anchor('adozioni/anagrafica/adozioni/order_by/a.nomecognome',__("Assistito", $module), array('id' => 'a.nomecognome'))?></th>
				<th><?php echo anchor('adozioni/anagrafica/adozioni/order_by/m.nome',__("Missione", $module))?></th>
				<th><?php echo anchor('adozioni/anagrafica/adozioni/order_by/ts.nome',__("Tipo Sostegno", $module))?></th>
				<th><?php echo anchor('adozioni/anagrafica/adozioni/order_by/sa.nome',__("Stato", $module))?></th>
				<th colspan="3" class="noprint"><?php echo __("Action", $module)?></th>
		</tr>
	</thead>
	<tbody>
<?php if ($rows) : ?>
<?php $i = $start+1; foreach ($rows as $row): ?>
<?php if ($i % 2 != 0): $rowClass = 'odd'; else: $rowClass = 'even'; endif;?>
		<tr class="<?php echo $rowClass?>">
				<td class="center"><?php echo $i?></td>
				<td class="center"><?php echo anchor('adozioni/anagrafica/adozioni/show/' . $row['id'], $row['id'], array('title' => __("Visualizza", $module)))?></td>
				<td><?php echo anchor('adozioni/anagrafica/sostenitori/show/'. $row['id_sostenitore'], $row['sostenitore']) ?></td>
				<td><?php echo anchor('adozioni/anagrafica/assistiti/show/'. $row['id_assistito'],$row['assistito']) ?></td>
				<td><?php echo $row['missione'] ?></td>
				<td><?php echo $row['tiposostegno'] ?></td>
				<td><?php echo $row['stato'] ?></td>
				<?php if($row['trashed'] == 1): ?>
				<td class="noprint"><?php echo anchor('adozioni/anagrafica/adozioni/restore/'. $row['id'], __("Ricovera", $module)) ?></td>
				<td class="noprint"><?php echo anchor('adozioni/anagrafica/adozioni/delete/'. $row['id'], __("Elimina", $module), array('class' => 'delete')) ?></td>
                <?php else: ?>
				<td><a href="<?php echo site_url('adozioni/contabilita/offerte/edit/id_sostenitore/' . $row['id_sostenitore'] . '/id_assistito/' . $row['id_assistito']); ?>" class="action"><?php echo __("Nuova offerta", $module) ?></a></td>
				<td class="noprint"><?php echo anchor('adozioni/anagrafica/adozioni/edit/'. $row['id'], __("Modifica", $module)) ?></td>
				<td class="noprint"><?php echo anchor('adozioni/anagrafica/adozioni/trash/'. $row['id'], __("Cestino", $module), array('class' => 'delete')) ?></td>
                <?php endif; ?>
		</tr>
<?php $i++; endforeach; ?>
<?php endif; ?>
</tbody>
</table>	

<?php echo $pager; ?>